class Solution
{
    public:
    int getLongestPalindrome(string s)
    {
        int ret = 1, n = s.size();
        for(int i = 1; i < n; i++)
        {
            // 当⻓度是奇数的时候
            int left = i - 1, right = i + 1;
            while(left >= 0 && right < n && s[left] == s[right])
            {
                left--;
                right++;
            }
            ret = max(ret, right - left - 1);
            // 当⻓度是偶数的时候
            left = i - 1, right = i;
            while(left >= 0 && right < n && s[left] == s[right])
            {
                left--;
                right++;
            }
            ret = max(ret, right - left - 1);
        }
        return ret;
    }
};